const { findMyPack} = require('../../../api/geData.js');
const { globalData } = getApp()
const util = require('../../../utils/util.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    gradeData: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getData()
  },
  onShow() {
    globalData.stopMoreClick = false
  },
  getData(){
    let that = this
    wx.request({
      url: globalData.baseUrl + '/findMyClass',
      data: {
        stu_id: wx.getStorageSync("userInfo").cluesOrStuId
      },
      method: 'POST',
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success(res) {
        if (res.data.code == 0) {
          that.solveData(res.data.data.myPackList)
        }
      }
    })
  },
  solveData(dataArr) {
    let gradeData = []
    dataArr.map(item => {
      if (item.status * 1 >= 6) {
        gradeData.push(item)
      }
    })
    let lesson = []
    lesson = util.listSolve(gradeData)
    this.setData({
      gradeData: lesson
    })
  },
  onPullDownRefresh() {
    this.getData()
    setTimeout(() => {
      wx.stopPullDownRefresh();
    }, 500)
  },
})